﻿#ifndef DEFINEITEMTYPE_H
#define DEFINEITEMTYPE_H

#include <QObject>
#include <QList>

enum DefineItemType
{
    DIT_AutoItem = 0,        // 自定义类型
    DIT_Rect,           // 矩形
    DIT_RectR,          // 旋转矩形
    DIT_Polygon,             // 多边形
    DIT_Circle,              // 圆
    DIT_CircleC,               // 同心圆
    DIT_Caliper,             // 卡尺
    DIT_Line,              // 直线
    DIT_Point,              // 点
};
Q_DECLARE_METATYPE(DefineItemType)
//矩形
struct DefRect
{
    DefRect():x(0),y(0),width(100),height(100)
    {
    }
    DefRect(float x,float y,float width,float height)
    {
        this->x = x;
        this->y = y;
        this->width = width;
        this->height = height;
    }
    DefRect(QPointF topLeftP,float width,float height)
    {
        this->x = topLeftP.x();
        this->y = topLeftP.y();
        this->width = width;
        this->height = height;
    }
    float x;
    float y;
    float width;
    float height;
};
Q_DECLARE_METATYPE(DefRect)
//旋转矩形
struct DefRectR
{
    DefRectR(){}
    DefRectR(float x, float y, float phi, float length1, float length2){
        this->y = y;
        this->x = x;
        this->phi = phi;
        this->length1 = length1;
        this->length2 = length2;
    }
    float x;
    float y;
    float phi;
    float length1;
    float length2;
};
Q_DECLARE_METATYPE(DefRectR)
//圆
struct DefCircle
{
    DefCircle(){}
    DefCircle(float x, float y, float radius){
        this->x = y;
        this->y = x;
        this->radius = radius;
    }
    float x;
    float y;
    float radius;
};
Q_DECLARE_METATYPE(DefCircle)
//同心圆
struct DefCircleC
{
    DefCircleC(){}
    DefCircleC(float x, float y, float radiusInner, float radiusOuter){
        this->x = x;
        this->y = y;
        rSmall = radiusInner;
        rBig = radiusOuter;
    }
    float x;
    float y;
    float rSmall;
    float rBig;
};
Q_DECLARE_METATYPE(DefCircleC)

//多边形
struct DefPolygon
{
    DefPolygon(){}
    DefPolygon(QList<QPointF> points){
        this->points = points;
    }
    QList<QPointF> points;
};
Q_DECLARE_METATYPE(DefPolygon)
//直线
struct DefLine
{
    DefLine():x1(0),y1(0),x2(0),y2(0)
    {}
    DefLine(float x1,float y1,float x2,float y2)
    {
        this->x1 = x1;
        this->x2 = x2;
        this->y1 = y1;
        this->y2 = y2;
    }
    DefLine(QPointF p1,QPointF p2)
    {
        this->x1 = p1.x();
        this->x2 = p2.x();
        this->y1 = p1.y();
        this->y2 = p2.y();
    }
    float x1;
    float y1;
    float x2;
    float y2;
};
Q_DECLARE_METATYPE(DefLine)

//卡尺
struct DefCaliper
{
    DefCaliper(){}
    DefCaliper(qreal x1, qreal y1, qreal x2, qreal y2, qreal height){
        this->x1 = x1;
        this->y1 = y1;
        this->x2 = x2;
        this->y2 = y2;
        this->height = height;
    }
    float x1;
    float y1;
    float x2;
    float y2;
    float height;
};
Q_DECLARE_METATYPE(DefCaliper)
//锚点
struct DefPoint
{
    DefPoint():x(0),y(0)
    {}
    DefPoint(float x,float y)
    {
        this->x = x;
        this->y = y;
    }
    DefPoint(QPointF p)
    {
        this->x = p.x();
        this->y = p.y();
    }
    float x;
    float y;
};
Q_DECLARE_METATYPE(DefPoint)


#endif // DEFINEITEMTYPE_H
